package com.sk.restree.controller;

import java.io.IOException;

import javax.servlet.RequestDispatcher;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

//move
public class MoveController extends HttpServlet {
	private static final long serialVersionUID = 1L;

	protected void doGet(HttpServletRequest request,
			HttpServletResponse response) throws ServletException, IOException {
		execute(request, response);
	}

	protected void doPost(HttpServletRequest request,
			HttpServletResponse response) throws ServletException, IOException {
		request.setCharacterEncoding("EUC-KR");
		execute(request, response);
	}

	private void execute(HttpServletRequest request,
			HttpServletResponse response) throws ServletException, IOException {
		String root = request.getContextPath();

		String act = request.getParameter("act");
		System.out.println("act===" + act);

		String path = "/index.jsp";
		boolean flag = true;

		if ("findbank".equals(act)) {
			path = "/findbank/findbank.jsp";
		} else if ("compfee".equals(act)) {
			path = "/compfee/compfee.jsp";
		} else if ("benefit".equals(act)) {
			path = "/benefit/benefit.jsp";
		} else if ("status".equals(act)) {
			path = "/status/status.jsp";
		} else if ("config".equals(act)) {
			path = "/config/config.jsp";
		} else if ("findbank2".equals(act)) {
			path = "/findbank/findbank2.jsp";
		} else if ("compfee2".equals(act)) {
			path = "/compfee/compfee2.jsp";
		} else if ("benefit2".equals(act)) {
			path = "/benefit/benefit2.jsp";
		} else if ("login".equals(act)) {
			path = "/member/login.jsp";
		}

		if (flag) {
			response.sendRedirect(root + path);
		} else {
			RequestDispatcher disp = request.getRequestDispatcher(path);
			disp.forward(request, response);
		}

	}

}
